

/*---------------------------------------------------------
   Initializes the effect. The data is a table of data 
   which was passed from the server.
---------------------------------------------------------*/
function EFFECT:Init( data )
	
	self.Ent = data:GetEntity()
	if self.Ent == nil or self.Ent == NULL then return end
	self.Pos = data:GetOrigin()
	self.Velocity 	= Vector( 0, 0, 1 )
	
	self.Emitter = ParticleEmitter( self.Pos )
	
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )
	if self.Ent == nil or self.Ent == NULL then 
		if self.Emitter then
			self.Emitter:Finish()
		end
	return false end
	if self.Ent:GetNetworkedBool("onfire",false) == false then self.Emitter:Finish() return false end
	if self.Ent:IsPlayer() then
		if not self.Ent:Alive() then
			self.Emitter:Finish() 
			return false
		end
	end
	
		for i=1,math.random(1,3) do
			self.Pos = self.Ent:LocalToWorld((self.Ent:OBBMaxs() * math.Rand(0,1)) + (self.Ent:OBBMins() * math.Rand(0,1)))
			local particle = self.Emitter:Add( "effects/muzzleflash"..math.random(1,4), self.Pos )
			
			particle:SetVelocity( (self.Velocity * math.Rand( 20, 55 )) + WindVector )
			particle:SetDieTime( math.Rand( 0.8, 1.3 ) )
			particle:SetStartAlpha( math.Rand( 180, 220 ) )
			particle:SetEndAlpha( 1 )
			particle:SetStartSize( math.Rand( 20, 30 ) )
			particle:SetEndSize( 0.1 )
			particle:SetRoll( math.Rand( 0, 360 ) )
			particle:SetRollDelta( math.Rand( -0.1, 0.1 ) )
			particle:SetColor( math.Rand( 150, 255 ), math.Rand( 100, 150 ), 100 )
			particle:VelocityDecay( false )
		end
			
		if math.random(1,3) == 1 then
			local particle = self.Emitter:Add( "particles/smokey", self.Pos )

			particle:SetVelocity( (self.Velocity * math.Rand( 50, 80 )) + WindVector )
			particle:SetDieTime( math.Rand( 0.7, 1.3 ) )
			particle:SetStartAlpha( math.Rand( 30, 60 ) )
			particle:SetEndAlpha( math.Rand( 1, 10 ) )
			particle:SetStartSize( math.Rand( 10, 20 ) )
			particle:SetEndSize( math.Rand( 40, 80 ) )
			particle:SetRoll( math.Rand( 0, 360 ) )
			particle:SetRollDelta( math.Rand( -0.1, 0.1 ) )
			particle:SetColor( 40,40,40 )
			particle:VelocityDecay( false )
		end
			
		if math.random(1,20) == 1 then
		
			local particle = self.Emitter:Add("effects/fire_embers"..math.random(1,3), self.Pos )
			particle:SetVelocity( (Vector(math.random(-15,15),math.random(-15,15),math.random(10,80)) * self.Velocity) + WindVector )
			particle:SetDieTime(math.Rand(2,4))
			particle:SetStartAlpha(math.random(140,220))
			particle:SetEndAlpha(10)
			particle:SetStartSize(math.Rand(3,4))
			particle:SetEndSize(0)
			particle:SetRoll(math.random(-200,200))
			particle:SetRollDelta( math.random( -1, 1 ) )
			particle:SetColor(255, 220, 100)
			particle:SetGravity(Vector(0,0,-200)) //-600 is normal
			particle:SetCollide(true)
			particle:SetBounce(0.1) 
		
		end
	
	return true
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	// Do nothing - this effect is only used to spawn the particles in Init
	
end



